package com.qf.homework.model.service.impl;

import com.qf.homework.entity.User;
import com.qf.homework.model.dao.UserDao;
import com.qf.homework.model.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<String> findName() {
        List<User> allUser = userDao.findAllName();
        List<String> nameList = new ArrayList<>();
        for (User user : allUser) {
            nameList.add(user.getName());
        }
        return nameList;
    }
}
